import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-03-20
 * Time: 19:05
 */
public class Main {
    //插入排序
    public static void demo1(int[] array){
        int[] str = Arrays.copyOf(array,array.length);
        AllSort allSort = new AllSort();
        long start = System.currentTimeMillis();
        allSort.Insert(str);
        long end = System.currentTimeMillis();
        System.out.println("插入排序: " + Arrays.toString(str) + " 耗时: " + (end - start));
    }
    //希尔排序
    public static void demo2(int[] array){
        int[] str = Arrays.copyOf(array,array.length);
        AllSort allSort = new AllSort();
        long start = System.currentTimeMillis();
        allSort.ShellSort(str);
        long end = System.currentTimeMillis();
        System.out.println("希尔排序: " + Arrays.toString(str) + " 耗时: " + (end - start));
    }
    //选择排序
    public static void demo3(int[] array){
        int[] str1 = Arrays.copyOf(array,array.length);
        int[] str2 = Arrays.copyOf(array,array.length);
        AllSort allSort = new AllSort();
        //
        long start1 = System.currentTimeMillis();
        allSort.Choice1(str1);
        long end1 = System.currentTimeMillis();
        //
        long start2 = System.currentTimeMillis();
        allSort.Choice2(str2);
        long end2 = System.currentTimeMillis();
        //
        System.out.println("选择排序1: " + Arrays.toString(str1) + " 耗时: " + (end1 - start1));
        System.out.println("选择排序2: " + Arrays.toString(str2) + " 耗时: " + (end2 - start2));
    }
    //堆排序
    public static void demo4(int[] array){
        int[] str = Arrays.copyOf(array,array.length);
        AllSort allSort = new AllSort();
        long start = System.currentTimeMillis();
        allSort.Heap(str);
        long end = System.currentTimeMillis();
        System.out.println("堆排序: " + Arrays.toString(str) + " 耗时: " + (end - start));
    }
    //冒泡排序
    public static void demo5(int[] array){
        int[] str = Arrays.copyOf(array,array.length);
        AllSort allSort = new AllSort();
        long start = System.currentTimeMillis();
        allSort.Bubble(str);
        long end = System.currentTimeMillis();
        System.out.println("冒泡排序: " + Arrays.toString(str) + " 耗时: " + (end - start));
    }
    //快速排序
    public static void demo6(int[] array){
        int[] str = Arrays.copyOf(array,array.length);
        AllSort allSort = new AllSort();
        //
        long start1 = System.currentTimeMillis();
        allSort.quickSort1(str);
        long end1 = System.currentTimeMillis();
        //
        long start2 = System.currentTimeMillis();
        allSort.quickSort2(array);
        long end2 = System.currentTimeMillis();
        //
        System.out.println("快速排序1: " + Arrays.toString(str) + " 耗时: " + (end1 - start1));
        System.out.println("快速排序2: " + Arrays.toString(str) + " 耗时: " + (end2 - start2));
    }
    public static void main(String[] args) {
        int[] array = new int[]{10,9,8,7,6,5,4,3,2,1};
        demo1(array);
        demo2(array);
        demo3(array);
        demo4(array);
        demo5(array);
        demo6(array);
    }
}